package com.google.code.twiddling.core.command.builtin;

import java.io.PrintWriter;
import java.util.List;

import com.google.code.twiddling.core.command.AbstractCommand;
import com.google.code.twiddling.core.command.Command;
import com.google.code.twiddling.core.command.CommandContext;
import com.google.code.twiddling.core.history.HistoryManager;

/**
 * @author <a href="mailto:yy.young@gmail.com">Young Yang</a>
 * @create Dec 22, 2008 8:42:29 PM
 */
@Command(name="history", description="show history commands performed in this session",
		usage="history [OPTION]...", example="history")
public class HistoryCommand extends AbstractCommand {

    public void doExecute(CommandContext context) throws Exception {
        PrintWriter out = context.getIO().getOut();
        List<String> historyCommands = HistoryManager.getInstance().getHistoryCommands();
        for(int i=0; i<historyCommands.size(); i++ ) {
            out.println(i + ". " + historyCommands.get(i));
        }
    }

}
